package org.zsl.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.zsl.model.Product;
import org.zsl.model.ResponseMessage;
import org.zsl.service.ProductService;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/pro")
@CrossOrigin
public class ProductController {

      @Autowired
      private ProductService productService;

     @RequestMapping("/list")
      public List<Product> getList(){

          return  productService.getList();
      }


    @RequestMapping("/list2")
    public List<Product> getListByExample(Product product){

        return  productService.getListByExample(product);
    }

      @RequestMapping(value = "/edit",method = RequestMethod.POST)
      public ResponseMessage add(Product product){

          System.out.println("productId:"+product.getProductId());
         return  productService.edit(product);
      }



}
